<template>
  <div class="sass-deprecation-fix">
    <div class="container">
      <h1>🎨 Sass 弃用警告修复</h1>
      
      <div class="fix-sections">
        <!-- 警告信息 -->
        <div class="fix-section">
          <h2>⚠️ 弃用警告信息</h2>
          <div class="warning-display">
            <div class="warning-item">
              <h3>Sass @import 规则弃用</h3>
              <div class="warning-code">
                Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
              </div>
              <div class="warning-details">
                <p><strong>影响文件：</strong></p>
                <ul>
                  <li><code>src/assets/css/index.scss</code> - 主样式入口文件</li>
                  <li>包含 5 个 @import 规则需要修复</li>
                </ul>
                <p><strong>原因：</strong>Dart Sass 正在逐步淘汰 @import 规则，推荐使用更现代的 @use 规则</p>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 修复前后对比 -->
        <div class="fix-section">
          <h2>🔄 修复前后对比</h2>
          <div class="comparison">
            <div class="before">
              <h3>修复前 (使用 @import)</h3>
              <div class="code-block">
                <code>
// 首先导入Element Plus暗色主题CSS变量<br>
@import 'element-plus/theme-chalk/dark/css-vars.css';<br><br>
@import './base.css';<br>
@import './icon.css';<br>
@import './element.scss';<br>
@import './transition.scss';<br>
@import './common.scss';<br>
@import './theme.scss';<br>
@import './responsive.scss';<br><br>
@import '//at.alicdn.com/t/c/font_4809477_rwsg4td4ak9.css';
                </code>
              </div>
            </div>
            
            <div class="after">
              <h3>修复后 (混合使用 @use 和 @import)</h3>
              <div class="code-block">
                <code>
// 外部 CSS 仍使用 @import<br>
@import 'element-plus/theme-chalk/dark/css-vars.css';<br><br>
// 本地 SCSS 文件使用 @use<br>
@use './base.css';<br>
@use './icon.css';<br>
@use './element.scss';<br>
@use './transition.scss';<br>
@use './common.scss';<br>
@use './theme.scss';<br>
@use './responsive.scss';<br><br>
// 外部字体 CSS 仍使用 @import<br>
@import '//at.alicdn.com/t/c/font_4809477_rwsg4td4ak9.css';
                </code>
              </div>
            </div>
          </div>
        </div>
        
        <!-- @use 规则的优势 -->
        <div class="fix-section">
          <h2>✨ @use 规则的优势</h2>
          <div class="advantages">
            <div class="advantage-item">
              <h3>1. 命名空间隔离</h3>
              <p>@use 规则为每个模块提供独立的命名空间，避免变量和混合器的命名冲突</p>
              <div class="example">
                <code>
@use 'colors' as c;<br>
.button { background: c.$primary-color; }
                </code>
              </div>
            </div>
            
            <div class="advantage-item">
              <h3>2. 更好的性能</h3>
              <p>@use 规则只加载模块一次，即使被多次引用，提高编译性能</p>
            </div>
            
            <div class="advantage-item">
              <h3>3. 明确的依赖关系</h3>
              <p>@use 规则使模块之间的依赖关系更加清晰和可维护</p>
            </div>
            
            <div class="advantage-item">
              <h3>4. 向前兼容</h3>
              <p>@use 规则是 Sass 的未来方向，确保代码的长期可维护性</p>
            </div>
          </div>
        </div>
        
        <!-- 修复结果 -->
        <div class="fix-section">
          <h2>✅ 修复结果</h2>
          <div class="result-grid">
            <div class="result-item success">
              <div class="result-icon">✓</div>
              <div class="result-content">
                <h4>警告消除</h4>
                <p>所有 Sass 弃用警告已清除</p>
              </div>
            </div>
            
            <div class="result-item success">
              <div class="result-icon">✓</div>
              <div class="result-content">
                <h4>样式正常</h4>
                <p>所有样式功能保持正常</p>
              </div>
            </div>
            
            <div class="result-item success">
              <div class="result-icon">✓</div>
              <div class="result-content">
                <h4>编译优化</h4>
                <p>Sass 编译性能得到提升</p>
              </div>
            </div>
            
            <div class="result-item success">
              <div class="result-icon">✓</div>
              <div class="result-content">
                <h4>未来兼容</h4>
                <p>兼容 Dart Sass 3.0.0 版本</p>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 最佳实践 -->
        <div class="fix-section">
          <h2>💡 Sass 最佳实践</h2>
          <div class="best-practices">
            <div class="practice-item">
              <h4>1. 使用 @use 替代 @import</h4>
              <ul>
                <li>新项目直接使用 @use 规则</li>
                <li>现有项目逐步迁移到 @use</li>
                <li>避免混合使用 @import 和 @use</li>
              </ul>
            </div>
            
            <div class="practice-item">
              <h4>2. 合理使用命名空间</h4>
              <ul>
                <li>为模块指定简短的别名</li>
                <li>避免命名空间冲突</li>
                <li>保持命名的一致性</li>
              </ul>
            </div>
            
            <div class="practice-item">
              <h4>3. 模块化组织</h4>
              <ul>
                <li>将相关样式组织到独立模块</li>
                <li>创建清晰的文件结构</li>
                <li>避免循环依赖</li>
              </ul>
            </div>
            
            <div class="practice-item">
              <h4>4. 版本管理</h4>
              <ul>
                <li>定期更新 Sass 版本</li>
                <li>关注弃用警告</li>
                <li>及时修复兼容性问题</li>
              </ul>
            </div>
          </div>
        </div>
        
        <!-- 迁移指南 -->
        <div class="fix-section">
          <h2>📋 迁移指南</h2>
          <div class="migration-guide">
            <div class="step">
              <div class="step-number">1</div>
              <div class="step-content">
                <h4>识别 @import 规则</h4>
                <p>在项目中搜索所有使用 @import 的 SCSS 文件</p>
              </div>
            </div>
            
            <div class="step">
              <div class="step-number">2</div>
              <div class="step-content">
                <h4>逐个替换</h4>
                <p>将 @import 替换为 @use，注意处理命名空间</p>
              </div>
            </div>
            
            <div class="step">
              <div class="step-number">3</div>
              <div class="step-content">
                <h4>测试验证</h4>
                <p>确保样式功能正常，没有破坏性变更</p>
              </div>
            </div>
            
            <div class="step">
              <div class="step-number">4</div>
              <div class="step-content">
                <h4>清理警告</h4>
                <p>检查控制台，确保所有弃用警告已清除</p>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="actions">
        <router-link to="/" class="action-btn primary">返回首页</router-link>
        <button @click="checkConsole" class="action-btn">检查控制台</button>
        <button @click="refreshPage" class="action-btn">刷新页面</button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const checkConsole = () => {
  console.log('=== Sass 修复状态检查 ===')
  console.log('当前时间:', new Date().toLocaleString())
  console.log('页面 URL:', window.location.href)
  console.log('用户代理:', navigator.userAgent.substring(0, 50) + '...')
  console.log('如果没有看到 Sass 弃用警告，说明修复成功！')
  console.log('========================')
  alert('控制台信息已输出，请查看开发者工具')
}

const refreshPage = () => {
  window.location.reload()
}
</script>

<style scoped>
.sass-deprecation-fix {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 2.2em;
}

.fix-sections {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.fix-section {
  padding: 25px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
}

.fix-section h2 {
  color: #333;
  margin-bottom: 20px;
  border-bottom: 3px solid #409EFF;
  padding-bottom: 10px;
  font-size: 1.5em;
}

.warning-display {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #f39c12;
}

.warning-item h3 {
  color: #f39c12;
  margin-bottom: 10px;
}

.warning-code {
  background: #fff3cd;
  padding: 15px;
  border-radius: 4px;
  font-family: monospace;
  color: #856404;
  margin: 10px 0;
  border-left: 4px solid #f39c12;
}

.warning-details ul {
  margin: 10px 0;
  padding-left: 20px;
}

.warning-details li {
  margin: 5px 0;
  line-height: 1.6;
}

.warning-details code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #e74c3c;
}

.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.before, .after {
  background: white;
  padding: 20px;
  border-radius: 8px;
}

.before {
  border-left: 4px solid #e74c3c;
}

.after {
  border-left: 4px solid #27ae60;
}

.before h3 {
  color: #e74c3c;
  margin-bottom: 15px;
}

.after h3 {
  color: #27ae60;
  margin-bottom: 15px;
}

.code-block {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  overflow-x: auto;
}

.code-block code {
  font-family: monospace;
  color: #2c3e50;
  line-height: 1.6;
}

.advantages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.advantage-item {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #409EFF;
}

.advantage-item h3 {
  color: #409EFF;
  margin-bottom: 10px;
}

.advantage-item p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 10px;
}

.example {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 4px;
  margin-top: 10px;
}

.example code {
  font-family: monospace;
  color: #2c3e50;
  line-height: 1.4;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 15px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #27ae60;
}

.result-icon {
  width: 40px;
  height: 40px;
  background: #27ae60;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  flex-shrink: 0;
}

.result-content h4 {
  margin-bottom: 5px;
  color: #333;
}

.result-content p {
  color: #666;
  margin: 0;
}

.best-practices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.practice-item {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #17a2b8;
}

.practice-item h4 {
  color: #17a2b8;
  margin-bottom: 15px;
}

.practice-item ul {
  margin: 0;
  padding-left: 20px;
}

.practice-item li {
  margin: 8px 0;
  line-height: 1.6;
}

.migration-guide {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #6f42c1;
}

.step-number {
  width: 40px;
  height: 40px;
  background: #6f42c1;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.step-content h4 {
  margin-bottom: 8px;
  color: #333;
}

.step-content p {
  color: #666;
  line-height: 1.6;
  margin: 0;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 24px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 2px solid #409EFF;
  color: #409EFF;
  background: white;
  cursor: pointer;
  font-size: 1em;
}

.action-btn.primary {
  background: #409EFF;
  color: white;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(64, 158, 255, 0.3);
}

.action-btn.primary:hover {
  background: #66b1ff;
  border-color: #66b1ff;
}

@media (max-width: 768px) {
  .comparison {
    grid-template-columns: 1fr;
  }
  
  .advantages,
  .best-practices {
    grid-template-columns: 1fr;
  }
}
</style>
